package htmltemplate

import (
	"github.com/gin-gonic/gin"
	"net/http"
)

/**
gin支持加载HTML模板, 然后根据模板参数进行配置并返回相应的数据，本质上就是字符串替换
TIPS：需要在 routers.go 使用gin.Default().LoadHTMLGlob() 指定模板文件位置，这里指定为 " tem/* " 文件夹下
*/
func HtmlRendering(ctx *gin.Context) {

	ctx.HTML(http.StatusOK, "index.html", gin.H{"name": "steven", "title": "gin框架学习", "company": "提普斯科技有限公司"})
}

/*
重定向
*/
func Redirect(ctx *gin.Context) {

	ctx.Redirect(http.StatusMovedPermanently, "https://juejin.im/")
}

func Redirect1(ctx *gin.Context) {

	ctx.Redirect(http.StatusMovedPermanently, "http://windata.gaotime.com/templates/page/similarityk/likeK.html")
}

func Redirect2(ctx *gin.Context) {

	ctx.Redirect(http.StatusMovedPermanently, "http://windata.gaotime.com/templates/page/teacherSelect/teacherSelect.html")
}

func Redirect3(ctx *gin.Context) {

	ctx.Redirect(http.StatusMovedPermanently, "http://windata.gaotime.com/templates/page/index/index.html")
}
